package com.study.config;

import com.study.bean.Person;
import com.study.service.BookService;
import org.springframework.context.annotation.*;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

/**
 * @author wuwenbo
 * @date 2020/3/27 - 16:40
 */
//配置类 == 配置文件
@Configuration //告诉Spring这是一个配置类
/*@ComponentScan(value = "com.study" ,includeFilters =  {
//        @Filter(type= FilterType.ANNOTATION, classes = {Controller.class}),
//        @Filter(type= FilterType.ASSIGNABLE_TYPE, classes = {BookService.class}),
        @Filter(type=FilterType.CUSTOM, classes = {MyTypeFilter.class})
}, useDefaultFilters = false)*/
//@ComponentScan value ：指定要扫描的包(针对这四个注解  @Controller,@Service,@Repository,@Component)
//excludeFilters = Filter[] ，指定扫描的时候按什么规则排除哪些组件
//includeFilters = Filter[] ，指定扫描的时候按什么规则包含哪些组件(需要禁用默认的扫描规则，因为默认是扫描所有组件)
//FilterType.ANNOTATION : 按照注解
//FilterType.ASSIGNABLE_TYPE : 按照给定的类型
//FilterType.ASPECTJ : 使用 ASPECTJ 表达式
//FilterType.REGEX : 使用正则表达式
//FilterType.CUSTOM : 使用自定义规则

public class MainConfig {
    //给容器中注册一个 Bean;类型为返回值的类型；id默认是用方法名
/*    @Bean("person")//我们可以在括号中修改bean的id
    public Person person(){
        return new Person("wuwenbo",123);
    }*/
}

//ComponentScans 可以配置多个扫描
//@ComponentScans(value={@ComponentScan(value = "com.study" ,includeFilters =  {
//        @Filter(type= FilterType.ANNOTATION, classes = {Service.class,Controller.class})
//},useDefaultFilters = false)})

//@ComponentScan(value = "com.study" ,excludeFilters = {
//        @Filter(type= FilterType.ANNOTATION, classes = {Service.class,Controller.class})
//})